/**
 * 
 */
package com.easidea.tim.entity.finance;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.springside.core.dao.extend.Undeletable;

import com.easidea.tim.entity.BaseEntity;
import com.easidea.tim.entity.saleorder.SaleOrder;

/**
 * @author Harrison
 *
 */
@Entity(name = "tim_finance_duefrom")
@org.hibernate.annotations.Entity(dynamicInsert = true, dynamicUpdate = true)
@Undeletable(status = "deleted")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "tim_finance_duefrom")
public class DueFrom extends BaseEntity {

    /**
	 * 
	 */
	private static final long serialVersionUID = 70016760388476653L;
	
	private Double amount; /* 本次应收金额 */
//    private StockCheckInOut stockCheckInOut; /* 对应出入库记录 */
    private DueFromSummary dueFromSummary; /* 应收总记录 */
    private List<DueFromPayedRecord> dueFromPayedRecordList; // 支付记录
  //  private FinanceItem item; // 记账科目
    private SaleOrder order;//销售订单
	@OneToOne(cascade = CascadeType.PERSIST)
    @JoinColumn(name="sales_order_id")       
    public SaleOrder getOrder() {
		return order;
	}

	public void setOrder(SaleOrder order) {
		this.order = order;
	}

	/**
     * @return the amount
     */
    @Column(name = "amount")
    public Double getAmount() {
        return amount;
    }

    /**
     * @param amount the amount to set
     */
    public void setAmount(Double amount) {
        this.amount = amount;
    }

//    /**
//     * @return the stockCheckInOut
//     */
//    @OneToOne(fetch = FetchType.LAZY)
//    @JoinColumn(name = "stockcheckinout_id", columnDefinition = "bigint not null")
//    public StockCheckInOut getStockCheckInOut() {
//        return stockCheckInOut;
//    }
//
//    /**
//     * @param stockCheckInOut the stockCheckInOut to set
//     */
//    public void setStockCheckInOut(StockCheckInOut stockCheckInOut) {
//        this.stockCheckInOut = stockCheckInOut;
//    }

    /**
     * @return the dueFromSummary
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "duefromsummary_id", nullable = false)
    public DueFromSummary getDueFromSummary() {
        return dueFromSummary;
    }

    /**
     * @param dueFromSummary the dueFromSummary to set
     */
    public void setDueFromSummary(DueFromSummary dueFromSummary) {
        this.dueFromSummary = dueFromSummary;
    }

	/**
	 * @return the dueFromPayedRecordList
	 */
    @OneToMany(fetch=FetchType.LAZY, mappedBy="dueFrom")
	public List<DueFromPayedRecord> getDueFromPayedRecordList() {
		return dueFromPayedRecordList;
	}

	/**
	 * @param dueFromPayedRecordList the dueFromPayedRecordList to set
	 */
	public void setDueFromPayedRecordList(
			List<DueFromPayedRecord> dueFromPayedRecordList) {
		this.dueFromPayedRecordList = dueFromPayedRecordList;
	}

//	/**
//	 * @return the item
//	 */
//	@ManyToOne(fetch=FetchType.LAZY)
//	@JoinColumn(name="finance_item_id", nullable=false)
//	public FinanceItem getItem() {
//		return item;
//	}
//
//	/**
//	 * @param item the item to set
//	 */
//	public void setItem(FinanceItem item) {
//		this.item = item;
//	}


}
